<html>
<head><meta charset="utf-8"><title>no bounds checks · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html">no bounds checks</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197611229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197611229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amit Levy <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197611229">(May 14 2020 at 20:12)</a>:</h4>
<p>What is a good way to disable bounds checks on slices? <span class="user-mention" data-user-id="302357">@Natalie Popescu</span> and I are doing some benchmarking on Rust workloads for our research, trying to understand performance regressions in various edge cases. <span class="user-mention" data-user-id="302357">@Natalie Popescu</span> has sort of brute forced disabling them with modifications to the compiler, but the results seem... wrong, so we're wondering if someone knows a tried and true way to do this.</p>



<a name="197614276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197614276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197614276">(May 14 2020 at 20:35)</a>:</h4>
<p>there's no compiler flag or library way, really, but the intent is to swap hot spots to get_unchecked (which is unsafe) if necessary</p>



<a name="197615151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197615151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amit Levy <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197615151">(May 14 2020 at 20:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> indeed. In our own, hand written, benchmarks we did that, but now trying to do so for a whole library of packages pulled from <a href="http://crates.io">crates.io</a>. The goal is really just get numbers---e.g. how much does bounds-checking "cost" (there are some degenerate cases where the answer is <em>a lot</em> but we think there are some things we can do in LLVM to ameliorate that). Someone on discord suggested removing length assertions from the MIR building code, which <em>sounds</em> promising, so we're going to try and figure out what that means and then do it :)</p>



<a name="197615203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197615203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197615203">(May 14 2020 at 20:43)</a>:</h4>
<p>yeah, I think that'll work for slices -- depends on what you want exactly</p>



<a name="197615221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197615221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197615221">(May 14 2020 at 20:43)</a>:</h4>
<p>e.g. stuff like <code>vec.remove(idx)</code> it won't cover probably</p>



<a name="197615942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197615942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amit Levy <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197615942">(May 14 2020 at 20:49)</a>:</h4>
<p>Oh that makes sense. Yeah, slices is plenty for now. We're really just fishing for examples of pre-existing code in libraries that might hit these regressions</p>



<a name="197615994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/no%20bounds%20checks/near/197615994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amit Levy <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/no.20bounds.20checks.html#197615994">(May 14 2020 at 20:49)</a>:</h4>
<p>And slices are ubiquitously used enough where I think we'll probably get lucky. Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>